package com.example.mr5.mygame.gameBattleCity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.Toast;

import com.example.mr5.mygame.R;
import com.example.mr5.mygame.gameBattleCity.screen.GameScene;
import com.example.mr5.mygame.gameBattleCity.screen.GameoverScreen;
import com.example.mr5.mygame.gameBattleCity.screen.ScoreScreen;
import com.example.mr5.mygame.gameBattleCity.screen.SplashScreen;
import com.example.mr5.mygame.gameBattleCity.screen.StageScreen;
import com.example.mr5.mygame.gameBattleCity.screen.StartScreen;

/**
 * Created by Mr.5
 * Date：2016/5/8.
 * Time：14:18
 */
public class BattleCity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE); 

        ResourceManager.loadResources(this);
        ResourceManager.startScreen=new StartScreen(this);
        ResourceManager.gameScene = new GameScene(this);
		ResourceManager.splashScreen = new SplashScreen(this);
		ResourceManager.gameoverScreen = new GameoverScreen(this);
		ResourceManager.scoreScreen = new ScoreScreen(this);
		ResourceManager.stageScreen = new StageScreen(this);

		
        setContentView(R.layout.activity_battle_city);
        mainWindow=(FrameLayout)findViewById(R.id.mainwindow);
        ResourceManager.theDisplay=mainWindow;
        ResourceManager.theDisplay.addView(ResourceManager.startScreen);
        ResourceManager.theDisplay.addView(ResourceManager.gameScene);
		ResourceManager.theDisplay.addView(ResourceManager.splashScreen);
		ResourceManager.theDisplay.addView(ResourceManager.gameoverScreen);
		ResourceManager.theDisplay.addView(ResourceManager.scoreScreen);
		ResourceManager.theDisplay.addView(ResourceManager.stageScreen);
        
        if(ResourceManager.currentScreen==null){
            ResourceManager.currentScreen=ResourceManager.startScreen;
         }
         ResourceManager.setCurrentScreen(ResourceManager.currentScreen); 
    }
    
    private FrameLayout mainWindow;

    @Override
    public void onBackPressed() {
        new AlertDialog.Builder(BattleCity.this).setTitle("你好")
                .setMessage("是否退出游戏？")
                .setPositiveButton("是", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                }).setNegativeButton("否", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
            }
        }).show();

    }
    
}